์ฐธ๊ณ :
https://supabase.com/docs/guides/database/database-advisors?queryGroups=lint&lint=0010_security_definer_view
์์ธ
์ํ๋ฒ ์ด์ค์์๋ ๋ทฐ๋ฅผ ๋ง๋ค๋ฉด ๊ธฐ๋ณธ์ ์ผ๋ก SECURITY DEFINER ๋ก ๋ง๋ค์ด์ง๋ค๊ณ ํ๋ค.
ํฌ์คํธ๊ทธ๋ ์ค์์ ๋ทฐ๋ SECURITY DEFINER ํน์ SECURITY INVOKER ์ค์ ์ ๊ฐ์ง๊ณ ๋ง๋ค ์ ์๋ค.
SECURITY DEFINER๋ก ๋ง๋ค์ด์ง ๋ทฐ๋ ํจ์๋
- ๊ทธ ์ฌ์ฉ์๊ฐ ๊ทธ๊ฒ๋ค์ ๋ง๋ ์ฌ์ฉ์์ ๊ถํ์ ๋ชจ๋ ์ฌ์ฉํ ์ ์๋ค.
- ์ ์ ๊ถํ์ ๊ฐ์ง ์ฌ๋์ด ๋ง์ ๊ถํ์ด ํ์ํ ์ ๋ณด๋ฅผ ์กฐํํ ์ ์๋ค๋ ์ ์์ ์ฅ์ ๊ณผ ๋จ์ ์ด ๊ณต์กดํ๋ค.
- ํนํ ์ํ๋ฒ ์ด์ค์ row level security๋ฅผ ๋ฌด๋ ฅํํ๊ธฐ ๋๋ฌธ์ ๊ฐํ๊ฒ ๊ถ์ฅํ์ง ์๋๋ค๊ณ .
ํด๊ฒฐ
๋ทฐ๋ฅผ ๋ง๋ค๋ DDL์ ๋ฐ๋ก security definer๊ฐ ์๋ security invoker๋ก ์ค์ ํ๋ ์ ์ ๋ฃ์ด์ฃผ์ด์ผ ํ๋ค.
create view public.v_example
with (security_invoker=on) -- ์ด๊ฑธ ์ถ๊ฐํด security invoker ๋ทฐ๋ก ์ค์ ํด์ผํ๋ค.
as select
....